package com.twetec.cms.common.constant;

import java.util.HashMap;
import java.util.Map;

public class ConstantsEnum {
    /**
     * 权限类型
     */
    public static enum PermissionType {
        MENU("MENU", "菜单"),
        BUTTON("BUTTON", "按钮");

        private final String value;
        private final String name;

        private PermissionType(String value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public String getName() {
            return name;
        }

        // 整理返回数据, 键值对
        public static Map<String, String> list() {
            Map<String, String> list = new HashMap<>();
            for (PermissionType permissionType : PermissionType.values()) {
                String name = permissionType.getName();
                list.put(String.valueOf(permissionType), name);
            }

            return list;
        }

        // 通过value获取name
        public static String getNameByValue(String value) {
            String name = "";
            for (PermissionType permissionType : PermissionType.values()) {
                if (permissionType.getValue().equals(value)) {
                    name = permissionType.getName();
                }
            }

            return name;
        }

    }

    /**
     * 证件类型
     */
    public static enum CredentialType {
        ID_CARD("ID_CARD", "身份证"),
        PASSPORT_CARD("PASSPORT_CARD", "护照"),
        TAIWAN_COMPATRIOTS_CARD("TAIWAN_COMPATRIOTS_CARD", "台胞证"),
        GO_HOME_CARD("GO_HOME_CARD", "回乡证");

        private final String value;
        private final String name;

        private CredentialType(String value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public String getName() {
            return name;
        }

        // 整理返回数据, 键值对
        public static Map<String, String> list() {
            Map<String, String> list = new HashMap<>();
            for (CredentialType credentialType : CredentialType.values()) {
                String name = credentialType.getName();
                list.put(String.valueOf(credentialType), name);
            }

            return list;
        }

        // 通过value获取name
        public static String getNameByValue(String value) {
            String name = "";
            for (CredentialType credentialType : CredentialType.values()) {
                if (credentialType.getValue().equals(value)) {
                    name = credentialType.getName();
                }
            }

            return name;
        }
    }

    /**
     * 性别
     */
    public static enum Gender {
        MALE("MALE", "男性"),
        FEMALE("FEMALE", "女性");

        private final String value;
        private final String name;

        private Gender(String value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public String getName() {
            return name;
        }

        // 整理返回数据, 键值对
        public static Map<String, String> list() {
            Map<String, String> list = new HashMap<>();
            for (Gender gender : Gender.values()) {
                String name = gender.getName();
                list.put(String.valueOf(gender), name);
            }

            return list;
        }

        // 通过value获取name
        public static String getNameByValue(String value) {
            String name = "";
            for (Gender gender : Gender.values()) {
                if (gender.getValue().equals(value)) {
                    name = gender.getName();
                }
            }

            return name;
        }
    }

    /**
     * 禁用/启用
     */
    public static enum Enable {
        ON("ON", "启用"),
        OFF("OFF", "禁用");

        private final String value;
        private final String name;

        private Enable(String value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public String getName() {
            return name;
        }

        // 整理返回数据, 键值对
        public static Map<String, String> list() {
            Map<String, String> list = new HashMap<>();
            for (Enable enable : Enable.values()) {
                String name = enable.getName();
                list.put(String.valueOf(enable), name);
            }

            return list;
        }

        // 通过value获取name
        public static String getNameByValue(String value) {
            String name = "";
            for (Enable enable : Enable.values()) {
                if (enable.getValue().equals(value)) {
                    name = enable.getName();
                }
            }

            return name;
        }
    }


}
